import com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator;

import java.util.*;

class Student1 {
	String name;
	Integer age;
	String major;
	public Student1(String name, Integer age, String major) {
		this.name = name;
		this.age = age;
		this.major = major;
	}
	@Override
	public String toString() {
		return "Student1{" +
				"name='" + name + '\'' +
				", age=" + age +
				", major='" + major + '\'' +
				'}';
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}
	public String getMajor() {
		return major;
	}
	public void setMajor(String major) {
		this.major = major;
	}
}
public class MyArrayList {
	public static void main1(String[] args) {
		List<Student1> list=new ArrayList<>();
		Student1 student1=new Student1("张三",18,"java");
		Student1 student2=new Student1("李四",19,"Phtyon");
		Student1 student3=new Student1("赵四",22,"嵌入式");
		Student1 student4=new Student1("王五",45,"C++");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		list.add(student4);
		System.out.println(list);
		for (Student1 stu:list) {
			System.out.println(stu.getName()+" "+stu.getAge()+" "+stu.getMajor());
		}
	}

	public static void main(String[] args) {
		List<Integer> list=new ArrayList<>();
		List<Integer> list1=new ArrayList<>();
		list.add(1);
		list.add(6);
		list.add(5);
		list.add(7);
		list.add(4);
		for (Integer x: list) {
			if(x>3) {
				list1.add(x);
			}
		}
		System.out.println(list);
		System.out.println(list1);
//		list.removeAll(list1);
//		System.out.println(list);
		Iterator<Integer> iterator=list.iterator();
		while(iterator.hasNext()) {
			Integer it = iterator.next();
			//迭代器在自己删除的时候，不能判断下一个是否大于3然后进行删除
			//只能判断当前是否大于3然后进行删除。
			//因为，迭代器他自己会进行向下跳，后面的数据给他删除了，并不会把后面的数据往前移动。
			if (it > 3) {
				iterator.remove();
			}
		}
		System.out.println(list);
		Random random=new Random();
		int len= random.nextInt(100);
		System.out.println(len);
	}
}

class Emplyemo {
	String name;
	int age;

	public Emplyemo(String name, int age) {
		this.name = name;
		this.age = age;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Emplyemo emplyemo = (Emplyemo) o;
		return age == emplyemo.age && Objects.equals(name, emplyemo.name);
	}
	@Override
	public int hashCode() {
		return Objects.hash(name, age);
	}
}
class Myset {
	public static void main(String[] args) {
		HashSet<Emplyemo> set=new HashSet<>();
		set.add(new Emplyemo("张三",18));
		set.add(new Emplyemo("张三",18));
		set.add(new Emplyemo("李四",19));
		set.add(new Emplyemo("王五",21));
		for ( Emplyemo emplyemo: set) {
			System.out.println(emplyemo.name+" "+emplyemo.age);
		}
	}
}
class MyLinkedList {
	public static void main(String[] args) {
		LinkedList<Integer> list = new LinkedList<>();
		list.add(1);
		list.add(3);
		list.add(4);
		list.add(5);
		list.add(6);
		System.out.println(list);
		int len = list.get(1);
		System.out.println(len);

		System.out.println(list.getFirst());
		System.out.println(list.getLast());
		LinkedList<Integer> list1 = new LinkedList<>();
		list1.push(18);
		System.out.println(list1);
		System.out.println(list1.peek());
		list1.add(0, 77);
		System.out.println(list1.indexOf(3));//获取元素对应的下标，不存在返回-1

		System.out.println(list1.element());//获取第一个元素
		for (Integer in : list1) {
			System.out.println(in);
		}
		//快速添加元素到集合的办法中
		List<Integer> list2 = Arrays.asList(45, 78, 89, 101, 12);
		List<String> list3 = Arrays.asList("zhangsan", "lisi", "wangwu");

	}
}
class Dog1{
	String name;
	Integer age;

	public Dog1(String name, int age) {
		this.name = name;
		this.age = age;
	}
}
class Person1 implements Comparable<Person1>{
	String name;
	Integer age;

	@Override
	public int compareTo(Person1 o) {
		int nameCompare=this.name.compareTo(o.name);
		int ageCompare=this.age.compareTo(o.age);
		return nameCompare==0?ageCompare:nameCompare;
	}
}
class MyTreeSet {
	public static void main1(String[] args) {
		TreeSet<Integer> treeset=new TreeSet<>();
		treeset.add(23);
		treeset.add(2);
		treeset.add(17);
		treeset.add(5);
		treeset.add(18);
		treeset.add(88);
		System.out.println(treeset);
		TreeSet<String> treeset1=new TreeSet<>();
		treeset1.add("black");
		treeset1.add("apple");
		treeset1.add("anna");
		treeset1.add("white");
		treeset1.add("red");
		treeset1.add("green");
		treeset1.add("adcd");
		treeset1.add("abc");
		System.out.println(treeset1);
		//当类型是自定义类型的时候，需要重写compareTo方法
		//比较器的一种写法
		TreeSet<Dog1> treeSet=new TreeSet<>((o1,o2)->{
			int len= o1.name.compareTo(o2.name);
			int len1=o1.age.compareTo(o2.age);
			return len==0?len:len1;
		});
		//正常写法是写一个比较器类，然后重写compareTo方法，继承comparator接口
		//能使这个类能进行比较的话，实现compareable接口
		treeSet.add(new Dog1("zhangsan",18));
		treeSet.add(new Dog1("zhangsan",18));
		treeSet.add(new Dog1("lisi",17));
		treeSet.add(new Dog1("wangwu",19));
		System.out.println(treeSet);
		for (Dog1 o1:treeSet) {
			System.out.println(o1.name+" "+o1.age);
		}
	}

	public static void main(String[] args) {
		//链表回文结构，当我们把数据插入到这个list中的时候，再去比较的话，用equals去比较
		List<Integer> list=new ArrayList<>();
		list.add(-129);
		list.add(-129);
		int i=0;
		int j=list.size()-1;
		//System.out.println(list.get(i));
		while(i<j) {
			if(!Objects.equals(list.get(i), list.get(j))) {
				System.out.println("222222");
			}
			i++;
			j--;
		}
		System.out.println("1111111111");
	}
}
class Circle {
	double  radius;
	public double findArea(double radius) {
		return Math.pow(radius,2)*Math.PI;
	}
	public static void main(String[] args) {
		Circle circle=new Circle();
		System.out.println(circle.findArea(5.0));
	}
}
